<template>
    <div id="messageBoard" :style="{height:height, width: width}" >
        <div :style="{ borderBottom:borderBottom }">
            <h1 :style="{marginBottom:zeroPx}"><i class="el-icon-data-board"></i> 留言板</h1>
        </div>
        <el-form :label-position="'top'" :model="ruleForm" status-icon :rules="rules" ref="ruleForm"
                 label-width="100px" class="demo-ruleForm">
            <el-form-item label="标题" prop="title"><el-input type="text" v-model="ruleForm.title" autocomplete="off"></el-input></el-form-item>
            <el-form-item label="内容" prop="content"><el-input :resize="'none'" :row="'2'" type="textarea" v-model="ruleForm.content"></el-input></el-form-item>

            <el-form-item>
                <el-button type="primary"  @click="submitForm('ruleForm')">提交</el-button>
                <el-button @click="resetForm('ruleForm')">重置</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
    export default {
        name: "MessageBoard",
        data() {
            return {
                borderBottom:'1px solid #000',
                textDecoration: 'underline',
                height:'310px',
                width: '300px',
                zeroPx: '0px',
                ruleForm: {
                    title: '',
                    content: ''
                },
                rules: {
                    title: [
                        {
                            required: true,
                            message:'留言标题不可为空',
                            trigger: 'blur'
                        }
                    ],
                    content:[
                        {
                            required: true,
                            message:'留言内容不可为空',
                            trigger: 'blur'
                        }
                    ]
                }
            };
        },
        methods: {
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {

                    } else {
                        console.log('提交失败!');
                        return false;
                    }
                });
            },
            resetForm(formName) {
                this.$refs[formName].resetFields();
            }
        }
    }
</script>

<style>
#messageBoard{
    padding: 0px 10px;
    /*上右下左 不写的那一个 跟对面的一样*/
}

.el-form-item{
    margin-bottom: 20px;
}

.el-form--label-top .el-form-item__label {
    padding: 0 0 3px;
}
</style>